home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / mac / tkMacInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  10.2 KB  |  283 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tkMacInt.h --
  3.  *
  4.  *    Declarations of Macintosh specific shared variables and procedures.
  5.  *
  6.  * Copyright (c) 1995-1997 Sun Microsystems, Inc.
  7.  *
  8.  * See the file "license.terms" for information on usage and redistribution
  9.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10.  *
  11.  * SCCS: @(#) tkMacInt.h 1.64 97/08/06 21:28:42
  12.  */
  13.  
  14. #ifndef _TKMACINT
  15. #define _TKMACINT
  16.  
  17. #include "tkInt.h"
  18. #include "tkPort.h"
  19.  
  20. #ifndef _TKMAC
  21. #    include "tkMac.h"
  22. #endif /* _TKMAC */
  23.  
  24.  
  25. #include <AppleEvents.h>
  26. #include <Windows.h>
  27. #include <QDOffscreen.h>
  28.  
  29. #define TK_MAC_68K_STACK_GROWTH (256*1024)
  30.  
  31. struct TkWindowPrivate {
  32.     TkWindow *winPtr;         /* Ptr to tk window or NULL if Pixmap */
  33.     GWorldPtr portPtr;         /* Either WindowRef or off screen world */
  34.     int xOff;                   /* X offset from toplevel window */
  35.     int yOff;                   /* Y offset from toplevel window */
  36.     RgnHandle clipRgn;        /* Visable region of window */
  37.     RgnHandle aboveClipRgn;    /* Visable region of window & it's children */
  38.     int referenceCount;        /* Don't delete toplevel until children are
  39.                  * gone. */
  40.     struct TkWindowPrivate *toplevel;    /* Pointer to the toplevel
  41.                      * datastruct. */
  42.     int flags;            /* Various state see defines below. */
  43. };
  44. typedef struct TkWindowPrivate MacDrawable;
  45.  
  46. /*
  47.  * This list is used to keep track of toplevel windows that have a Mac
  48.  * window attached. This is useful for several things, not the least
  49.  * of which is maintaining floating windows.
  50.  */
  51.  
  52. typedef struct TkMacWindowList {
  53.     struct TkMacWindowList *nextPtr;    /* The next window in the list. */
  54.     TkWindow *winPtr;            /* This window */
  55. } TkMacWindowList;
  56.  
  57. /*
  58.  * Defines use for the flags field of the MacDrawable data structure.
  59.  */
  60.  
  61. #define TK_SCROLLBAR_GROW    1
  62. #define TK_CLIP_INVALID        2
  63. #define TK_HOST_EXISTS        4
  64. #define TK_DRAWN_UNDER_MENU    8
  65.  
  66. /*
  67.  * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
  68.  * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the
  69.  * TkWindow structure for the window,  but in the MacWin.  This way we can still tell
  70.  * what the correct port is after the TKWindow  structure has been freed.  This 
  71.  * actually happens when you bind destroy of a toplevel to Destroy of a child.
  72.  */
  73.  
  74. /*
  75.  * Defines used for TkMacInvalidateWindow
  76.  */
  77.  
  78. #define TK_WINDOW_ONLY 0
  79. #define TK_PARENT_WINDOW 1
  80.  
  81. /*
  82.  * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field
  83.  */
  84.  
  85. #define TkMacHostToplevelExists(tkwin) \
  86.     (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
  87.  
  88. /*
  89.  * Defines use for the flags argument to TkGenWMConfigureEvent.
  90.  */
  91.  
  92. #define TK_LOCATION_CHANGED    1
  93. #define TK_SIZE_CHANGED        2
  94. #define TK_BOTH_CHANGED        3
  95.  
  96. /*
  97.  * Variables shared among various Mac Tk modules but are not
  98.  * exported to the outside world.
  99.  */
  100.  
  101. extern int tkMacAppInFront;
  102. extern Tk_Window tkMacFocusWin;
  103.  
  104. /*
  105.  * Globals shared among Macintosh Tk
  106.  */
  107.  
  108. extern MenuHandle tkAppleMenu;        /* Handle to the Apple Menu */
  109. extern MenuHandle tkFileMenu;        /* Handles to menus */
  110. extern MenuHandle tkEditMenu;        /* Handles to menus */
  111. extern RgnHandle tkMenuCascadeRgn;    /* A region to clip with. */
  112. extern int tkUseMenuCascadeRgn;        /* If this is 1, clipping code
  113.                      * should intersect tkMenuCascadeRgn
  114.                      * before drawing occurs.
  115.                      * tkMenuCascadeRgn will only
  116.                      * be valid when the value of this
  117.                      * variable is 1. */
  118. extern TkMacWindowList *tkMacWindowListPtr;
  119.                     /* The list of toplevels */
  120.  
  121. /*
  122.  * The following types and defines are for MDEF support.
  123.  */
  124.  
  125. #if STRUCTALIGNMENTSUPPORTED
  126. #pragma options align=mac8k
  127. #endif
  128. typedef struct TkMenuLowMemGlobals {
  129.     long menuDisable;            /* A combination of the menu and the item
  130.                          * that the mouse is currently over. */
  131.     short menuTop;            /* Where in global coords the top of the
  132.                          * menu is. */
  133.     short menuBottom;            /* Where in global coords the bottom of
  134.                          * the menu is. */
  135.     Rect itemRect;            /* This is the rectangle of the currently
  136.                          * selected item. */
  137.     short scrollFlag;            /* This is used by the MDEF and the
  138.                          * Menu Manager to control when scrolling
  139.                          * starts. With hierarchicals, an
  140.                          * mChooseMsg can come before an
  141.                          * mDrawMsg, and scrolling should not
  142.                          * occur until after the mDrawMsg.
  143.                          * The mDrawMsg sets this flag;
  144.                          * mChooseMsg checks the flag and
  145.                          * does not scroll if it is set;
  146.                          * and then resets the flag. */
  147. } TkMenuLowMemGlobals;
  148. #if STRUCTALIGNMENTSUPPORTED
  149. #pragma options align=reset
  150. #endif
  151.  
  152. typedef pascal void (*TkMenuDefProcPtr) (short message, MenuHandle theMenu,
  153.     Rect *menuRectPtr, Point hitPt, short *whichItemPtr,
  154.     TkMenuLowMemGlobals *globalsPtr);
  155. enum {
  156.     tkUppMenuDefProcInfo = kPascalStackBased
  157.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  158.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(MenuRef)))
  159.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  160.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Point)))
  161.         | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short*)))
  162.         | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(TkMenuLowMemGlobals *)))
  163. };
  164.  
  165. #if GENERATINGCFM
  166. typedef UniversalProcPtr TkMenuDefUPP;
  167. #else
  168. typedef TkMenuDefProcPtr TkMenuDefUPP;
  169. #endif
  170.  
  171. #if GENERATINGCFM
  172. #define TkNewMenuDefProc(userRoutine)    \
  173.     (TkMenuDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), \
  174.     tkUppMenuDefProcInfo, GetCurrentArchitecture())
  175. #else
  176. #define TkNewMenuDefProc(userRoutine)     \
  177.     ((TkMenuDefUPP) (userRoutine))
  178. #endif
  179.  
  180. #if GENERATINGCFM
  181. #define TkCallMenuDefProc(userRoutine, message, theMenu, menuRectPtr, hitPt, \
  182.     whichItemPtr, globalsPtr) \
  183.     CallUniversalProc((UniversalProcPtr)(userRoutine), TkUppMenuDefProcInfo, \
  184.     (message), (theMenu), (menuRectPtr), (hitPt), (whichItemPtr), \
  185.     (globalsPtr))
  186. #else
  187. #define TkCallMenuDefProc(userRoutine, message, theMenu, menuRectPtr, hitPt, \
  188.     whichItemPtr, globalsPtr) \
  189.     (*(userRoutine))((message), (theMenu), (menuRectPtr), (hitPt), \
  190.     (whichItemPtr), (globalsPtr))
  191. #endif
  192.  
  193. /*
  194.  * Internal procedures shared among Macintosh Tk modules but not exported
  195.  * to the outside world:
  196.  */
  197.  
  198. extern int        HandleWMEvent _ANSI_ARGS_((EventRecord *theEvent));
  199. extern void         TkAboutDlg _ANSI_ARGS_((void));
  200. extern void        TkCreateMacEventSource _ANSI_ARGS_((void));
  201. extern void         TkFontList _ANSI_ARGS_((Tcl_Interp *interp,
  202.                 Display *display));
  203. extern Window        TkGetTransientMaster _ANSI_ARGS_((TkWindow *winPtr));
  204. extern int        TkGenerateButtonEvent _ANSI_ARGS_((int x, int y,
  205.                 Window window, unsigned int state));
  206. extern int         TkGetCharPositions _ANSI_ARGS_((
  207.                 XFontStruct *font_struct, char *string,
  208.                 int count, short *buffer));
  209. extern void        TkGenWMDestroyEvent _ANSI_ARGS_((Tk_Window tkwin));
  210. extern void        TkGenWMConfigureEvent _ANSI_ARGS_((Tk_Window tkwin,
  211.                 int x, int y, int width, int height, int flags));
  212. extern unsigned int    TkMacButtonKeyState _ANSI_ARGS_((void));
  213. extern void        TkMacClearMenubarActive _ANSI_ARGS_((void));
  214. extern int        TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr));
  215. extern int        TkMacDispatchMenuEvent _ANSI_ARGS_((int menuID, 
  216.                 int index));
  217. extern void        TkMacInstallCursor _ANSI_ARGS_((int resizeOverride));
  218. extern int        TkMacConvertTkEvent _ANSI_ARGS_((EventRecord *eventPtr,
  219.                 Window window));
  220. extern void        TkMacHandleTearoffMenu _ANSI_ARGS_((void));
  221. extern void        tkMacInstallMWConsole _ANSI_ARGS_((
  222.                 Tcl_Interp *interp));
  223. extern void        TkMacInvalClipRgns _ANSI_ARGS_((TkWindow *winPtr));
  224. extern void        TkMacDoHLEvent _ANSI_ARGS_((EventRecord *theEvent));
  225. extern void         TkMacFontInfo _ANSI_ARGS_((Font fontId, short *family,
  226.                 short *style, short *size));
  227. extern Time        TkMacGenerateTime _ANSI_ARGS_(());
  228. extern GWorldPtr     TkMacGetDrawablePort _ANSI_ARGS_((Drawable drawable));
  229. extern TkWindow *     TkMacGetScrollbarGrowWindow _ANSI_ARGS_((
  230.                 TkWindow *winPtr));
  231. extern Window         TkMacGetXWindow _ANSI_ARGS_((WindowRef macWinPtr));
  232. extern int        TkMacGrowToplevel _ANSI_ARGS_((WindowRef whichWindow,
  233.                 Point start));
  234. extern void         TkMacHandleMenuSelect _ANSI_ARGS_((long mResult,
  235.                 int optionKeyPressed));
  236. extern void        TkMacInitAppleEvents _ANSI_ARGS_((Tcl_Interp *interp));
  237. extern void         TkMacInitMenus _ANSI_ARGS_((Tcl_Interp     *interp));
  238. extern void        TkMacInvalidateWindow _ANSI_ARGS_((MacDrawable *macWin, int flag));
  239. extern int        TkMacIsCharacterMissing _ANSI_ARGS_((Tk_Font tkfont,
  240.                 unsigned int searchChar));
  241. extern void        TkMacMakeRealWindowExist _ANSI_ARGS_((
  242.                 TkWindow *winPtr));
  243. extern BitMapPtr    TkMacMakeStippleMap(Drawable, Drawable);
  244. extern void        TkMacMenuClick _ANSI_ARGS_((void));
  245. extern void        TkMacRegisterOffScreenWindow _ANSI_ARGS_((Window window,
  246.                 GWorldPtr portPtr));
  247. extern int        TkMacResizable _ANSI_ARGS_((TkWindow *winPtr));
  248. extern void        TkMacSetEmbedRgn _ANSI_ARGS_((TkWindow *winPtr, RgnHandle rgn));
  249. extern void        TkMacSetHelpMenuItemCount _ANSI_ARGS_((void));
  250. extern void        TkMacSetScrollbarGrow _ANSI_ARGS_((TkWindow *winPtr,
  251.                 int flag));
  252. extern void        TkMacSetUpClippingRgn _ANSI_ARGS_((Drawable drawable));
  253. extern void        TkMacSetUpGraphicsPort _ANSI_ARGS_((GC gc));
  254. extern void         TkMacUpdateClipRgn _ANSI_ARGS_((TkWindow *winPtr));
  255. extern void        TkMacUnregisterMacWindow _ANSI_ARGS_((GWorldPtr portPtr));
  256. extern int        TkMacUseMenuID _ANSI_ARGS_((short macID));
  257. extern RgnHandle     TkMacVisableClipRgn _ANSI_ARGS_((TkWindow *winPtr));
  258. extern void        TkMacWinBounds _ANSI_ARGS_((TkWindow *winPtr,
  259.                 Rect *geometry));
  260. extern void        TkMacWindowOffset _ANSI_ARGS_((WindowRef wRef, 
  261.                 int *xOffset, int *yOffset));
  262. extern void        TkResumeClipboard _ANSI_ARGS_((void));
  263. extern int         TkSetMacColor _ANSI_ARGS_((unsigned long pixel,
  264.                 RGBColor *macColor));
  265. extern void         TkSetWMName _ANSI_ARGS_((TkWindow *winPtr,
  266.                 Tk_Uid titleUid));
  267. extern void        TkSuspendClipboard _ANSI_ARGS_((void));
  268. extern int        TkWMGrowToplevel _ANSI_ARGS_((WindowRef whichWindow,
  269.                 Point start));
  270. extern int        TkMacZoomToplevel _ANSI_ARGS_((WindowPtr whichWindow, 
  271.                 Point where, short zoomPart));
  272. extern Tk_Window    Tk_TopCoordsToWindow _ANSI_ARGS_((Tk_Window tkwin,
  273.                 int rootX, int rootY, int *newX, int *newY));
  274. extern MacDrawable *    TkMacContainerId _ANSI_ARGS_((TkWindow *winPtr));
  275. extern MacDrawable *    TkMacGetHostToplevel  _ANSI_ARGS_((TkWindow *winPtr));
  276. /*
  277.  * The following prototypes need to go into tkMac.h
  278.  */
  279. EXTERN void        Tk_UpdatePointer _ANSI_ARGS_((Tk_Window tkwin,
  280.                 int x, int y, int state));
  281.  
  282. #endif /* _TKMACINT */
  283.